<%@ page isELIgnored="false" %>
<%@ page contentType="text/html" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>EM Live Ranking - Edit</title>
</head>
<body>

<form:form action="updateeditview.html" commandName="view">
  <form:select path="editView" items="${views}"/>
  <input type="submit" value="Update View"/>
</form:form>

<br/>Neuer Spieler:<br/><br/>

<form:form action="save.html" commandName="player">
  Name:<FONT color="red"><form:errors path="name"/></FONT><form:input path="name" size="55"/>
  Schläge:<FONT color="red"><form:errors path="score"/></FONT><form:input path="score"/>
  <input type="submit" value="Speichern"/>
</form:form>
<hr/>
Alle Spieler:
<table>

  <c:forEach items="${players.players}" varStatus="idx">
    <tr>
      <td>
        <form:form action="update.html" commandName="player[${idx.index}]">
          <form:hidden path="id"/>
          <form:hidden path="imageId"/>
          Name:<form:input path="name" size="30"/>
          <%--<form:errors path="apps[${idx.index}].BP"/>--%>
          Schläge:<form:input path="score" size="3"/>
          <form:select path="team" items="${teams}" itemLabel="name" itemValue="id"/>
          <form:select path="level" items="${levels}"/>
          <form:select path="tournament" items="${tournaments}" itemLabel="name" itemValue="id"/>
          <input type="submit" value="Update"/>
        </form:form></td>
      <td><img src="showImage.html?id=${players.players[idx.index].imageId}&dimension=25" height="25px"/></td>
      <c:if test="${view.editView == 'EXPERT'}">
        <td>
          <form method="post" action="upload.html?id=${players.players[idx.index].id}"
                enctype="multipart/form-data">
            <input type="text" name="id" value="${players.players[idx.index].id}" size="2"/>
            <input type="file" name="file" value="Datei" title="Datei"/>
            <input type="submit" value="Upload"/>
          </form>
        </td>
        <td><form:form action="deleteimage.html?id=${players.players[idx.index].id}" commandName="players">
          <form:hidden path="players[${idx.index}].id"/>
          <input type="submit" value="Bild Löschen"/>
        </form:form></td>
        <td><form:form action="delete.html?id=${players.players[idx.index].id}" commandName="players">
          <form:hidden path="players[${idx.index}].id"/>
          <input type="submit" value="Löschen"/>
        </form:form></td>
      </c:if>
    </tr>
  </c:forEach>
</table>
<%--<c:forEach items="${players}" var="player">--%>
<%--<form action="update.html" method="post">--%>
<%--<input type="text" value="${player.name}" name="name"/><input type="submit" value="Update"/>--%>
<%--<c:out value="${player.name}"/> - <c:out value="${player.score}"/></br>--%>
<%--</form>--%>
<%--</c:forEach>--%>
</body>
</html>